package inventory.service.impl;

import inventory.entity.Equipment;
import inventory.entity.Notice;
import inventory.entity.po.ReparationPo;
import inventory.mapper.EquipmentMapper;
import inventory.mapper.NoticeMapper;
import inventory.mapper.ReparationRecordMapper;
import inventory.service.FeedbackService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import java.util.UUID;

@Service
public class FeedbackServiceImpl implements FeedbackService {
    @Resource
    NoticeMapper noticeMapper;
    @Resource
    ReparationRecordMapper reparationRecordMapper;


    @Override
    public int addNotice(String launcher, String noticeContext) {
        Notice notice = new Notice();
        notice.setNoticeId(UUID.randomUUID().toString().replace("-",""));
        notice.setLauncher(launcher);
        notice.setNoticeContext(noticeContext);
        Date date = new Date();
        notice.setLaunchTime(date);
        int i = noticeMapper.insert(notice);
        return i;
    }


    @Override
    public int deleteNoticeById(String notice_id) {
        int i = noticeMapper.deleteByPrimaryKey(notice_id);
        return i;
    }

    @Override
    public int insert(ReparationPo reparationPo) {
        int i = reparationRecordMapper.insertReparationPo(reparationPo);
        return i;
    }

    @Override
    public int deleteReparationPo(String reparationId) {
        int i = reparationRecordMapper.deleteReparationById(reparationId);
        return i;
    }

    @Override
    public List<ReparationPo> selectReparationer(String reparationerId) {
        List<ReparationPo> reparationPos = reparationRecordMapper.selectByReparationerById(reparationerId);
        return reparationPos;
    }

    @Override
    public int updateReparationPo(String reparationId,String handleProgress) {
        System.out.println("service");
        System.out.println(handleProgress);
        int i = reparationRecordMapper.updateReparationById(reparationId,handleProgress);
        return i;
    }


}
